# Maintainer: Ray Donnelly <mingw.android@gmail.com>

_realname=rhash
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.3.9
pkgrel=1
pkgdesc="Great utility for computing hash sums (mingw-w64)"
arch=('any')
url='https://sourceforge.net/projects/rhash/'
depends=("${MINGW_PACKAGE_PREFIX}-gettext")
makedepends=("${MINGW_PACKAGE_PREFIX}-ruby")
license=('custom' 'BSD')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/rhash/RHash/archive/v${pkgver}.tar.gz"
        "${_realname}-${pkgver}.tar.gz.asc"::"https://github.com/rhash/RHash/releases/download/v${pkgver}/v${pkgver}.tar.gz.asc"
        "fix-po-file.patch")
sha256sums=('42b1006f998adb189b1f316bf1a60e3171da047a85c4aaded2d0d26c1476c9f6'
            'SKIP'
            'd9c46d169f104b08c496c33bf44db8cc44f18ac60af41a2bee43b2fcc23aa061')
validpgpkeys=('2875F6B1C2D27A4F0C8AF60B2A714497E37363AE')

prepare() {
  cd "${srcdir}"/RHash-${pkgver}
  patch -Np1 -i "${srcdir}/fix-po-file.patch"
}

build() {
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  cp -R "${srcdir}"/RHash-${pkgver} "${srcdir}"/build-${CARCH}
  cd "${srcdir}"/build-${CARCH}
  ./configure \
     --prefix=${MINGW_PREFIX} \
     --enable-lib-static \
     --enable-lib-shared
  make
}

check() {
  cd "${srcdir}"/build-${CARCH}
  make test test-shared test-static
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make -j1 install DESTDIR="${pkgdir}"
  make -j1 install install-gmo DESTDIR="${pkgdir}"

  # license
  # fully qualify path for this because there might be switch in
  # build systems.
  install -Dm644 ${srcdir}/RHash-${pkgver}/COPYING \
    "${pkgdir}${MINGW_PREFIX}"/share/licenses/rhash/LICENSE
}
